import axios from '@/utils/axios'

// 获取文章详情列表
export const getArticles = articleId => {
  return axios({
    method: 'GET',
    url: `/app/v1_0/articles/${articleId}`
  })
}

// 获取文章详情中评论列表
export const getComments = params => {
  return axios({
    method: 'GET',
    url: '/app/v1_0/comments',
    params
  })
}

// 关注用户
export const followings = authorId => {
  return axios({
    method: 'POST',
    url: '/app/v1_0/user/followings',
    data: {
      target: authorId
    }
  })
}

// 取消关注
export const unfollowing = authorId => {
  return axios({
    method: 'DELETE',
    url: `/app/v1_0/user/followings/${authorId}`
  })
}

// 收藏文章
export const collectArticle = articleId => {
  return axios({
    method: 'POST',
    url: '/app/v1_0/article/collections',
    data: {
      target: articleId
    }
  })
}

// 取消文章收藏
export const unCollectArticle = articleId => {
  return axios({
    method: 'DELETE',
    url: `/app/v1_0/article/collections/${articleId}`
  })
}

// 文章点赞
export const goodArticle = articleId => {
  return axios({
    method: 'POST',
    url: '/app/v1_0/article/likings',
    data: {
      target: articleId
    }
  })
}

// 取消文章点赞
// 文章点赞
export const unGoodArticle = articleId => {
  return axios({
    method: 'DELETE',
    url: `/app/v1_0/article/likings/${articleId}`
  })
}
